Socket
Socket
Sign inDemoInstall

vue-scrollto

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-scrollto

Adds a directive that listens for click events and scrolls to elements.


Version published
Weekly downloads
112K
increased by6.19%
Maintainers
1
Weekly downloads
 
Created

What is vue-scrollto?

vue-scrollto is a Vue.js directive that allows you to smoothly scroll to elements within your application. It provides a simple and flexible way to implement scrolling animations, making it easier to navigate through different sections of a page.

What are vue-scrollto's main functionalities?

Basic Usage

This feature allows you to scroll to a specific element on the page by using the v-scroll-to directive. In this example, clicking the button will smoothly scroll to the element with the id 'element'.

<template>
  <div>
    <button v-scroll-to="'#element'">Scroll to Element</button>
    <div id="element" style="margin-top: 1000px;">Target Element</div>
  </div>
</template>

<script>
import VueScrollTo from 'vue-scrollto';

export default {
  directives: {
    scrollTo: VueScrollTo.directive
  }
};
</script>

Custom Duration

This feature allows you to customize the duration of the scroll animation. In this example, the scroll to the target element will take 1000 milliseconds (1 second).

<template>
  <div>
    <button v-scroll-to="{ el: '#element', duration: 1000 }">Scroll to Element</button>
    <div id="element" style="margin-top: 1000px;">Target Element</div>
  </div>
</template>

<script>
import VueScrollTo from 'vue-scrollto';

export default {
  directives: {
    scrollTo: VueScrollTo.directive
  }
};
</script>

Offset

This feature allows you to set an offset for the scroll position. In this example, the scroll will stop 50 pixels before the target element.

<template>
  <div>
    <button v-scroll-to="{ el: '#element', offset: -50 }">Scroll to Element</button>
    <div id="element" style="margin-top: 1000px;">Target Element</div>
  </div>
</template>

<script>
import VueScrollTo from 'vue-scrollto';

export default {
  directives: {
    scrollTo: VueScrollTo.directive
  }
};
</script>

Easing

This feature allows you to specify an easing function for the scroll animation. In this example, the 'ease-in-out' easing function is used to create a smooth scroll effect.

<template>
  <div>
    <button v-scroll-to="{ el: '#element', easing: 'ease-in-out' }">Scroll to Element</button>
    <div id="element" style="margin-top: 1000px;">Target Element</div>
  </div>
</template>

<script>
import VueScrollTo from 'vue-scrollto';

export default {
  directives: {
    scrollTo: VueScrollTo.directive
  }
};
</script>

Other packages similar to vue-scrollto

Keywords

FAQs

Package last updated on 28 Oct 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc